package impl.gui.util;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

public class UDecideGUIElementFactory {

	private static final Color	foreGround			= new Color(0xFFFFFF);
	private static final Color	backGroundEnabled	= new Color(0xD72A24);
	private static final Color	backGroundDisabled	= new Color(0xFFE5D7);
	private static final Color	borderTitleColor	= new Color(0xAE0633);

	public static JButton getButton(String name) {
		JButton b = new JButton("<html><center>" + name + "</center></html>") {

			@Override
			public void setEnabled(boolean enabled) {
				super.setEnabled(enabled);

				if (!enabled) {
					setBackground(backGroundDisabled);
					setForeground(foreGround);
				} else {
					setBackground(backGroundEnabled);
					setForeground(foreGround);
				}
			}

		};
		b.setBackground(backGroundEnabled);
		b.setForeground(foreGround);
		b.setFont(getBigFont());

		return b;
	}

	public static JButton getButton(String name, String actionCommand) {
		JButton b = getButton(name);
		b.setActionCommand("showUAssertionDialog");

		return b;
	}

	public static JButton getButton(String name, boolean enabled) {
		JButton b = getButton(name);
		b.setEnabled(enabled);

		return b;
	}

	public static JButton getButton(String name, boolean enabled, String actionCommand) {
		JButton b = getButton(name);
		b.setEnabled(enabled);
		b.setActionCommand(actionCommand);

		return b;
	}

	public static Font getBigFont() {
		return new Font("Arial", Font.BOLD, 15);
	}

	public static Border getBorder(String text) {
		TitledBorder outerBorder = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), text);
		outerBorder.setTitleColor(borderTitleColor);
		Border innerBorder = BorderFactory.createEmptyBorder(3, 3, 3, 3);

		return BorderFactory.createCompoundBorder(outerBorder, innerBorder);
	}
}
